package com.wmeimob.fastboot.jiubei.controller;

import com.github.pagehelper.PageInfo;
import com.wmeimob.fastboot.core.context.PageContext;
import com.wmeimob.fastboot.jiubei.entity.ShopGoodsStatistics;
import com.wmeimob.fastboot.jiubei.service.ShopGoodsStatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @className ShopGoodsStatisticsController
 * @description 【商品统计】控制器
 * @author wjt
 * @date Mon Sep 07 00:55:01 CST 2020
 * @version 1.0
 **/
@RestController
@RequestMapping("shopGoodsStatistics")
@Slf4j
public class ShopGoodsStatisticsController {

    @Resource
    private ShopGoodsStatisticsService shopGoodsStatisticsService;




    /**
     * 商品统计分页查询
     * @param shopGoodsStatistics
     * @return
     */
    @GetMapping
    public PageInfo queryForShopGoodsStatistics(ShopGoodsStatistics shopGoodsStatistics){
        PageContext.startPage();
        return new PageInfo<ShopGoodsStatistics>(shopGoodsStatisticsService.list(shopGoodsStatistics));
         
    }

     /**
     * 商品统计导出
     * @param shopGoodsStatistics
     * @return
     */
    @PostMapping("/export")
    public List<ShopGoodsStatistics> queryForShopGoodsStatisticsExport(@RequestBody ShopGoodsStatistics  shopGoodsStatistics){
        return  shopGoodsStatisticsService.list(shopGoodsStatistics);
    }


    /**
     * 商品统计查询-<通过id查询>
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public ShopGoodsStatistics queryForShopGoodsStatisticsById(@PathVariable("id") Object id){
            return  shopGoodsStatisticsService.queryShopGoodsStatisticsById(id);
    }


    /**
     * 商品统计添加
     * @param shopGoodsStatistics
     * @return
     */
    @PostMapping
    public void insertForShopGoodsStatistics(@RequestBody ShopGoodsStatistics shopGoodsStatistics){
            shopGoodsStatisticsService.addShopGoodsStatistics(shopGoodsStatistics);    
    }


    /**
     * 商品统计修改
     * @param shopGoodsStatistics
     * @return
     */
    @PutMapping
    public void updateForShopGoodsStatistics(@RequestBody ShopGoodsStatistics shopGoodsStatistics){
            shopGoodsStatisticsService.modifyShopGoodsStatistics(shopGoodsStatistics);  
    }

    /**
     * 商品统计删除
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public void removeForShopGoodsStatistics(@PathVariable("id") Object id){
            shopGoodsStatisticsService.removeShopGoodsStatistics(id);
    }
}
